using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class Skill2Mage : MonoBehaviour
{
    // Start is called before the first frame update
    private Vector3 target;
    public float speed;
    public GameObject effect;
    

    private void Awake()
    {
        target = FindObjectOfType<MageController>().GetComponent<MageController>().targetPos;
        transform.DOMove(target,  (Vector3.Distance(target,transform.position)/speed)).SetEase(Ease.Linear);
        Destroy(gameObject,5f);
    }
    
    private void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.CompareTag("Enemy"))
        { 
            var collisionStats = other.gameObject.GetComponent<CharacterStats>();
            collisionStats.TakeDamage(SkillManager.Instance.SkillListMage.items[1].damage, collisionStats);
            Instantiate(effect, transform.position, Quaternion.identity);
            Destroy(this.gameObject);
           
            
        }
    }

   
}
